package com.itheima.sparkml.statices

import org.apache.spark.SparkConf
import org.apache.spark.mllib.linalg
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.stat.Statistics
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SparkSession

object _1CorrTest2 {
  def main(args: Array[String]): Unit = {
    val sparkConf=new SparkConf().setAppName("_1CorrTest2").setMaster("local[*]")
    val spark=SparkSession.builder().config(sparkConf).getOrCreate()
    val sc=spark.sparkContext
    sc.setLogLevel("WARN")
    val data: RDD[linalg.Vector] =sc.parallelize(Seq(
      Vectors.dense(1.0,2.0,8.0),
      Vectors.dense(2.0,4.0,16.0),
      Vectors.dense(5.0, 12.0, 24.0)))
    val matrix = Statistics.corr(data)
    println(matrix)
    sc.stop()
  }
}
